package com.jingfree.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.fyz.fymoduledemo.R;

import java.util.List;

/**
 * Created by fyz on 2018/3/15.
 */

public class ItemAdapter extends BaseAdapter {
    private Context mContext;
    private List list;

    public ItemAdapter(Context context, List list) {
        this.mContext = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();

            convertView = LayoutInflater.from(mContext).inflate(R.layout.layout_listview_item, null, true);
            viewHolder.textView = convertView.findViewById(R.id.text);

            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.textView.setText("aaaaa");

        return convertView;
    }

    class ViewHolder {
        private TextView textView;
    }
}
